<?php
/**
 * @author Anh Nguyen
 * @copyright 2012
 */
 
 defined('APP') or die('Denied access !');
 
 class Model
 { 
    protected $db;
    public function __construct()
    {
        $this->db = new mysqli(Core::$config['db_host'], Core::$config['db_user'], Core::$config['db_pass'], Core::$config['db_name']);
        if($this->db->error) {
            die('Cannot connect to database, error : ' . $this->db->error);
        }
        $this->db->query("SET NAMES 'UTF8'");
    }
    
    public function free($rs)
    {
        $rs->free();
        return $this;
    }
    
    public function sql_inject($string)
    {
        return $this->db->real_escape_string($string);
    }
 }
?>